package com.gy.education.home;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;

import com.gy.education.BaseFragment;
import com.gy.education.R;
import com.gy.education.utils.AnimUtil;
import com.zxing.MipcaActivityCapture;

/**
 * Created by 高岳 on 2016/7/12.
 * Describe:首页
 */
public class HomeFragment extends BaseFragment {

    private ImageView imgAdd,imgFriend,imgMessage;
    private WebView webView;

    @Override
    protected View setView(LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.fragment_home,null);
        hidenTop();
        return view;
    }

    @Override
    protected void initView() {
        webView = (WebView) _rootView.findViewById(R.id.home_webview);
        imgAdd = (ImageView) _rootView.findViewById(R.id.fg_home_title_img_add);
        imgFriend = (ImageView) _rootView.findViewById(R.id.fg_home_title_img_firend);
        imgMessage = (ImageView) _rootView.findViewById(R.id.fg_home_title_img_message);
    }

    @Override
    protected void initData() {
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
    }

    @Override
    protected void setListener() {
        super.setListener();
        imgAdd.setOnClickListener(this);
        imgFriend.setOnClickListener(this);
        imgMessage.setOnClickListener(this);
    }

    @Override
    protected void fillData() {
        super.fillData();

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        Intent intent;
        switch (v.getId()){
            case R.id.fg_home_title_img_add:
                intent = new Intent(mContext, MipcaActivityCapture.class);
                mContext.startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
            case R.id.fg_home_title_img_firend:
                intent = new Intent(mContext, FriendsActivity.class);
                mContext.startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
            case R.id.fg_home_title_img_message:
                intent = new Intent(mContext, MyMessageActivity.class);
                mContext.startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
        }
    }
}
